package com.redoor.app.stake.workflow.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.redoor.app.stake.workflow.model.BaseWorkorderOperationLog;
import com.redoor.app.stake.workflow.model.controllerModel.BaseWorkorderOperationLogCriteria;
import com.redoor.app.stake.workflow.service.BaseWorkorderOperationLogService;
import com.redoornetwork.framework.core.response.ResponseResult;
import com.redoornetwork.framework.core.response.ResultGenerator;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* Created by wangjunlei on 2018-03-07 17:06:26.
*/
@RestController
@RequestMapping("/base/workorder/operation/logs")
public class BaseWorkorderOperationLogController {

    @Autowired
    private BaseWorkorderOperationLogService baseWorkorderOperationLogService;

    @GetMapping
    public ResponseResult list(BaseWorkorderOperationLogCriteria criteria) {
        PageHelper.startPage(criteria.getPageNum(), criteria.getPageSize());
        List<BaseWorkorderOperationLog> list = baseWorkorderOperationLogService.findAll();
        PageInfo pageInfo = new PageInfo(list);
        return ResultGenerator.generatorSuccess(pageInfo);
    }

    @ApiOperation(value = "根据轨迹类型以及主键信息查询轨迹列表", notes = "")
    @PostMapping(value = "/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "workOrderUuid", value = "工单的主键uuid", paramType = "query", dataType = "String", required = true, defaultValue = "")
    })
    public ResponseResult list(String workOrderUuid) {
        List<BaseWorkorderOperationLog> list = baseWorkorderOperationLogService.getWorkOrderLogList(workOrderUuid);
        return ResultGenerator.generatorSuccess(list);
    }
}
